import java.util.Random;
import java.util.Scanner;
import java.util.Arrays;

public class qmNGuessNumber {
    public int[] generateAnswer() {
        int[] answer = new int[4];

        for (int a = 0; a < answer.length; a++) {
            answer[a] = -1;
        }
        int index = 0;

        while (index < answer.length) {
            Random rod = new Random();

            int num = rod.nextInt(10);

            if (judge(answer, num)) {
                answer[index++] = num;
            }
        }

        return answer;
    }

    public static boolean judge(int[] arr, int num) {
        for (int a = 0; a < arr.length; a++) {
            if (arr[a] == num) {
                return false;
            }
        }

        return true;
    }


    public int[] getPlayerInput() {
        int[] guess = new int[4];

        Scanner sc = new Scanner(System.in);

        for (int a = 0; a < 4; a++) {
            int temp = sc.nextInt();

            if (temp >= 0 && temp <= 9) {
                guess[a] = temp;
            }
        }

        System.out.println(Arrays.toString(guess));


        return guess;
    }


    public static int[] compareGuessAnswer(int[] answer, int[] guess) {
        int[] arr_AB = new int[2];

        int A = 0;
        int B = 0;

        for (int a = 0; a < 4; a++) {
            if (guess[a] == answer[a]) {
                A++;
            }
        }

        for (int a = 0; a < 4; a++) {
            for (int j = 0; j < 4; j++) {
                if (guess[a] == answer[j]) {
                    B++;
                }
            }
        }


        arr_AB[0] = A;
        arr_AB[1] = B;

        System.out.println("A = " + arr_AB[0] + ", B = " + arr_AB[1]);

        return arr_AB;
    }

    public static boolean isWin(int[] answer, int[] guess) {
        int A = compareGuessAnswer(answer, guess)[0];

        if (A == 4) {
            return true;
        }

        return false;
    }
}